<template>
  <div class="menuNavigation-box" :class="{ 'menuNavigation-item-wap': store.isMobileType }">
    <!-- 目录 -->
    <div class="menuNavigation-item" :class="{ 'hidden-popup': showPopup }" @click="openprogres" @mouseleave="leaveFn">
      <t-popup
        class="placement align"
        content="展览定位"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="menu-box">
          <img
            :src="publicUrls + 'free/style9/menuNavigation3-1.png'"
            alt=""
            class="frame-img top-left"
            :class="{ 'select-img': showType === 2 }"
          />
          <img
            :src="publicUrls + 'free/style9/menuNavigation3-2.png'"
            alt=""
            class="frame-img bottom-right"
            :class="{ 'select-img2': showType === 2 }"
          />
          <div
            class="menu-img"
            :style="{
              backgroundImage: `url(${publicUrls + 'free/style9/menuNavigation3.png?imageView2/format/webp'})`,
            }"
          >
          <div class="item-content freeIcon">&#xe663;</div>
          </div>
        </div>
      </t-popup>
    </div>
    <div
      class="menuNavigation-item"
      :class="{ 'hidden-popup': showPopup }"
      @click="handleMouseEnter(2)"
      @mouseleave="leaveFn"
    >
      <t-popup
        class="placement align"
        content="展览目录"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="menu-box">
          <img
            :src="publicUrls + 'free/style9/menuNavigation3-1.png'"
            alt=""
            class="frame-img top-left"
            :class="{ 'select-img': showType === 2 }"
          />
          <img
            :src="publicUrls + 'free/style9/menuNavigation3-2.png'"
            alt=""
            class="frame-img bottom-right"
            :class="{ 'select-img2': showType === 2 }"
          />
          <div
            class="menu-img"
            :style="{
              backgroundImage: `url(${publicUrls + 'free/style9/menuNavigation3.png?imageView2/format/webp'})`,
            }"
          >
            <div class="item-content doorIcon" :style="{ color: showType === 2 ? '#ffefd5' : '#fff' }">&#xe679;</div>
          </div>
        </div>
      </t-popup>
    </div>
    <!-- 更多板块 -->
    <div
      class="menuNavigation-item"
      :class="{ 'hidden-popup': showPopup }"
      id="menuNavigation-item"
      @click="handleMouseEnter(1)"
      @mouseleave="leaveFn"
    >
      <t-popup
        class="placement align"
        content="更多板块"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="menu-box">
          <img
            :src="publicUrls + 'free/style9/menuNavigation3-1.png'"
            alt=""
            class="frame-img top-left"
            :class="{ 'select-img': showType === 1 }"
          />
          <img
            :src="publicUrls + 'free/style9/menuNavigation3-2.png'"
            alt=""
            class="frame-img bottom-right"
            :class="{ 'select-img2': showType === 1 }"
          />
          <div
            class="menu-img"
            :style="{
              backgroundImage: `url(${publicUrls + 'free/style9/menuNavigation3.png?imageView2/format/webp'})`,
            }"
          >
            <div class="item-content doorIcon" :style="{ color: showType === 1 ? '#ffefd5' : '#fff' }">&#xe67a;</div>
          </div>
        </div>
      </t-popup>
    </div>
    <!-- 收藏 -->
    <div class="menuNavigation-item" @click="follow" v-if="!store.isMobileType">
      <t-popup
        class="placement align"
        content="收藏展览"
        placement="left"
        attach="#menuNavigation-tem"
        showArrow
        destroyOnClose
      >
        <div class="menu-box">
          <img :src="publicUrls + 'free/style9/menuNavigation3-1.png'" alt="" class="frame-img top-left" />
          <img :src="publicUrls + 'free/style9/menuNavigation3-2.png'" alt="" class="frame-img bottom-right" />
          <div
            class="menu-img"
            :style="{
              backgroundImage: `url(${publicUrls + 'free/style9/menuNavigation3.png?imageView2/format/webp'})`,
            }"
          >
            <div v-if="commonStore.isStart" class="item-content doorIcon item-start start-active">&#xe629;</div>
            <div v-else class="item-content doorIcon item-start">&#xe628;</div>
          </div>
        </div>
        <!-- <img :src="publicUrls + 'free/style9/menuNavigation3-hover.png'" alt="" class="menu-img hover-img" />
        <img :src="publicUrls + 'free/style9/menuNavigation3.png'" alt="" class="menu-img null-hover-img" /> -->
      </t-popup>
    </div>
    <!-- 分享 -->
    <div class="menuNavigation-item" v-if="!store.isMobileType">
      <t-popup
        class="placement align"
        content=""
        placement="left"
        attach="#menuNavigation-tem"
        destroyOnClose
        :trigger="store.isMobileType ? 'click' : 'hover'"
        :overlay-inner-style="(triggerElem) => ({ background: `transparent`, 'box-shadow': 'none' })"
      >
        <template #content>
          <Shear @shearType="shearType" />
        </template>
        <div class="menu-box">
          <img :src="publicUrls + 'free/style9/menuNavigation3-1.png'" alt="" class="frame-img top-left" />
          <img :src="publicUrls + 'free/style9/menuNavigation3-2.png'" alt="" class="frame-img bottom-right" />
          <div
            class="menu-img"
            :style="{
              backgroundImage: `url(${publicUrls + 'free/style9/menuNavigation3.png?imageView2/format/webp'})`,
            }"
          >
            <div class="item-content doorIcon">&#xe647;</div>
          </div>
        </div>
      </t-popup>
    </div>
    <!-- 展开目录 -->
    <div
      class="scroll-box"
      :class="showType === 1 || showType === 2 || showType === 4 ? 'scroll-box-active' : 'scroll-box-down'"
    >
      <div class="scroll-content-box">
        <div class="content-title">
          {{ showType === 1 ? '更多板块' : showType === 2 ? '单元目录' : showType === 4 ? '分享展览' : '' }}
        </div>
        <img :src="publicUrls + 'free/style9/divideLine.png'" alt="" class="divide-line" />
        <div class="list">
          <div class="list-content" v-if="showType === 1">
            <RouterList @emitPath="scrollHandleMouseLeave" />
          </div>
          <div class="list-content" v-if="showType === 2">
            <div class="list-scroll" :class="{ 'list-scroll2': store.templateMOdeList.length < 7 }">
              <div class="item" @click="scroolPath(item.id)" v-for="item in store.templateMOdeList" :key="item.id">
                <p class="item-title" :class="{ 'title-hover': listId === item.id }">{{ item.text }}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div
      @wheel="pageWheel"
      class="shadow"
      @click="close"
      v-if="(showType === 1 || showType === 2 || showType === 4) && show"
    ></div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style9',
});
</script>
<script lang="ts" setup>
import { getHeardToken } from '@/api/utils';
import { psthOutline } from '@/hooks/menuHooks';
import RouterList from '../menuComponent/routerList9.vue';
import { publicUrls } from '@/utils/minxin';
import { ref, reactive, watch, nextTick, computed, defineComponent } from 'vue';
import { useProjectStore } from '@/store';
import ScrollBox from '../scrollBox.vue';
import style1 from './style/style1.vue';
import { commonDataStore } from '@/store';
import { toQQ, toQQzone, toWeibo } from '@/utils/shear';
import { AddFollow } from '@/api/door/door';
import Shear from '../menuComponent/templateShear.vue';
import { useRoute, useRouter } from 'vue-router';

const props = defineProps({
  isMobile: {
    type: Boolean,
  },
});
const commonStore = commonDataStore();
const show = ref(false);
const showPopup = ref(false);
const showType = ref(0);
const listId = ref(0);
const store = useProjectStore();
const visibleMessage = ref(false);
const FollowType = ref(false);
const router = useRouter();
const route = useRoute();
const Scrollwidth = ref();
const shareList = reactive([
  {
    icon: '\ue623',
    text: '分享此展览到QQ',
  },
  {
    icon: '\ue616',
    text: '分享此展览到QQ空间',
  },
  {
    icon: '\ue615',
    text: '分享此展览到微博',
  },
]);

commonStore.getMenuList();
const handleMouseEnter = (type: number) => {
  showType.value = type;
  show.value = true;
  showPopup.value = true;
};
const openprogres = () => {
  store.setprogressVisible();
};
const leaveFn = () => {
  showPopup.value = false;
};
let viewportwidth = window.innerWidth;
Scrollwidth.value = (viewportwidth / 900) * 300;

const getScrollWidth = computed(() => {
  let widths = (window.innerWidth / 900) * 300;
  return widths;
});

const mouseenterHover = () => {};

const scrollHandleMouseLeave = () => {
  showType.value = 0;
  show.value = false;
};
const scroolPath = (id: number) => {
  if (route.name !== 'templateedit') {
    router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
    store.menuId = null;
  }

  setTimeout(() => {
    psthOutline('Level1outline' + id);
    scrollHandleMouseLeave();
    listId.value = id;
  }, 200);
};
const follow = () => {
  let token = getHeardToken();
  if (!token) {
    // visibleMessage.value = true;
    store.loginModeShow = true;
    return;
  } else {
    commonStore.setFollow();
    handleMouseEnter(3);
  }
};
const pageWheel = (event: any) => {
  const delta = Math.sign(event.wheelDelta || -event.detail);
  const scrollContainer = document.getElementById('edit-scroll-box');
  if (delta > 0) {
    if (scrollContainer.scrollLeft === 0) {
    } else {
      scrollContainer.scrollLeft = scrollContainer.scrollLeft - 100;
    }
  } else {
    scrollContainer.scrollLeft = scrollContainer.scrollLeft + 100;
  }
  event.preventDefault();

  // scrollRef
};
//分享
const shearType = (e: number) => {
  let url = window.location.href;
  let title = '';
  handleMouseEnter(4);
  switch (e) {
    case 0:
      toQQ(url, title);
      break;
    case 1:
      toQQzone(url, title);
      break;
    case 2:
      toWeibo(url, title);
      break;
  }
  scrollHandleMouseLeave();
};

//取消登录
const closeClick = () => {
  visibleMessage.value = false;
};
const close = () => {
  showType.value = 0;
  show.value = false;
};
//确认登录
const pathSubmitClick = () => {
  visibleMessage.value = false;
  let url = window.location.href;
  let redirectUrl = 'http://wz.wuzhan.art/#/login?redirect=' + url;
  window.location.href = redirectUrl;
};
watch(
  () => store.templateMOdeList,
  () => {},
  { deep: true },
);
</script>

<style lang="less" scoped>
a {
  color: #000;
  &:hover {
    color: #000;
  }
}
.menuNavigation-box {
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 60px;
  right: 20px;
  // right: 0px;
  width: 50px;
  z-index: 999;
}
.menuNavigation-item {
  width: 50px;
  height: 50px;
  margin-top: 24px;
  cursor: pointer;
}
.menu-box {
  position: relative;
  width: 100%;
  height: 100%;
}
.menu-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 46px;
  height: 46px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.menu-box:hover {
  .item-content {
    color: #ffefd5 !important;
  }
  .top-left {
    display: none !important;
  }
  .bottom-right {
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
  }
}
.select-img {
  display: none;
}
.select-img2 {
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
}
.frame-img {
  width: 46px;
  height: 46px;
  object-fit: cover;
}
.top-left {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}
.bottom-right {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 2;
}
.item-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 28px;
  height: 28px;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.start-active {
  color: #ffefd5;
}
.hover-img {
  display: none;
}
.null-hover-img {
  display: block;
}
.hidden-popup {
  ::v-deep .t-popup__content {
    display: none;
  }
}
.menuNavigation-item:hover {
  .hover-img {
    display: block;
  }
  .null-hover-img {
    display: none;
  }
}
::v-deep .t-popup__content {
  display: flex;
  padding: 2px 12px;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border-radius: 4px;
  background: #706454;
  color: #fff;
  font-family: 'MicrosoftYaHei';
  font-size: 16px;
  font-weight: 400;
  line-height: 180%; /* 28.8px */
  box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}
::v-deep .t-popup__arrow::before {
  background: #706454;
  box-shadow: none !important;
}
.shadow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}
.scroll-box {
  display: flex;
  align-items: center;
  position: fixed;
  bottom: 40px;
  right: 78px;
  z-index: 1000;
}
.scroll-box-down {
  width: 294px;
  opacity: 0;
  display: none;
  height: 0;
}
.scroll-content-box {
  flex-shrink: 0;
  width: 294px;
  height: 420px;
  background: url('https://static.jiyi.show/free/style9/scrollMenuBg.png') no-repeat center/100% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: 14px 19px 18px 19px;
}
.content-title {
  color: #fff3d2;
  text-align: center;
  font-family: 'SourceHanSerifCN';
  font-size: 18px;
  font-style: normal;
  font-weight: 700;
  line-height: 180%; /* 32.4px */
  align-self: stretch;
}
.divide-line {
  width: 100%;
  height: 6px;
  object-fit: cover;
  margin-top: 4px;
}
.list {
  flex: 1;
  margin-top: 8px;
  width: 100%;
}
.list-content {
  width: 100%;
}
.list-scroll {
  width: 100%;
  height: 310px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  overflow: auto;
  scrollbar-width: none;
  &::-webkit-scrollbar {
    display: none;
  }
}
.list-scroll2 {
  justify-content: flex-start;
}
.item {
  margin-bottom: 14px;
  cursor: pointer;
  &:last-child {
    margin-bottom: 0;
  }
}
.item:hover {
  .item-title {
    color: #fff3d2;
  }
}
.title-hover {
  color: #fff3d2 !important;
}
.item-title {
  color: #fff;
  text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.2);
  font-family: 'PingFangSC';
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 200%; /* 32px */
}
.menuNavigation-item-wap {
  bottom: 100px;

  .menuNavigation-item {
    // transform: translateZ(1px);
    transform: scale(1.5) translateZ(2px);
    margin-top: 42px;
  }
  .scroll-box {
    transform: scale(1.3) translateZ(2px);
    margin-bottom: 80px;
    right: 210px;
  }
  ::v-deep .t-popup {
    display: none;
  }
}
</style>
